import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JPopupMenu;


/**
 * to set the popuplistener
 * @author Ronny
 *
 */
class PopupListener extends MouseAdapter {
    JPopupMenu popup;
    public static JButton selectedref;
    public static int xpos, ypos;
    PopupListener(JPopupMenu popupMenu) {
        popup = popupMenu;
    }

    public void mousePressed(MouseEvent e) {
        showPopup(e);
    }

    public void mouseReleased(MouseEvent e) {
    	selectedref=(JButton)e.getSource();
        
    	showPopup(e);
    }

    private void showPopup(MouseEvent e) {
        if (e.isPopupTrigger()) {
            popup.show(e.getComponent(),
                       e.getX(), e.getY());
           
            
            xpos=e.getComponent().getX();
            ypos=e.getComponent().getY();
           
        }
        
    }
}